"""
Case Type   : 功能测试
Case Name   : 修改参数max_concurrent_autonomous_transactions值为-1,1025,小数,合理报错
Create At   : 2024/7/3
Owner       : peilinqian
Description :
    step1:设置max_concurrent_autonomous_transactions参数值为-1;
    step2:设置max_concurrent_autonomous_transactions参数值为1025;
    step3:设置max_concurrent_autonomous_transactions参数值为小数;
Expect      :
    step1:设置max_concurrent_autonomous_transactions参数值为-1; expect：设置失败
    step2:设置max_concurrent_autonomous_transactions参数值为1025; expect：设置失败
    step3:设置max_concurrent_autonomous_transactions参数值为小数; expect：设置失败
History     :
"""
import os
import unittest

from testcase.utils.Common import Common
from testcase.utils.CommonSH import CommonSH
from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger


class DblinkCase(unittest.TestCase):
    def setUp(self):
        self.log = Logger()
        self.log.info(f'----{os.path.basename(__file__)}:初始化----')
        self.pri_sh = CommonSH('PrimaryDbUser')
        self.com = Common()
        self.constant = Constant()

    def test_main(self):
        step_txt = '----step1:设置max_concurrent_autonomous_transactions' \
                   '参数值为-1; expect：设置失败----'
        self.log.info(step_txt)
        msg = self.pri_sh.execute_gsguc(
            'set', self.constant.GSGUC_SUCCESS_MSG,
            f"max_concurrent_autonomous_transactions=-1", )
        self.assertFalse(msg, '执行失败:' + step_txt)

        step_txt = '----step2:设置max_concurrent_autonomous_transactions' \
                   '参数值为1025; expect：设置失败----; '
        self.log.info(step_txt)
        msg = self.pri_sh.execute_gsguc(
            'set', self.constant.GSGUC_SUCCESS_MSG,
            f"max_concurrent_autonomous_transactions=1025", )
        self.assertFalse(msg, '执行失败:' + step_txt)

        step_txt = '----step3:设置max_concurrent_autonomous_transactions' \
                   '参数值为小数; expect：设置失败----'
        self.log.info(step_txt)
        msg = self.pri_sh.execute_gsguc(
            'set', self.constant.GSGUC_SUCCESS_MSG,
            f"max_concurrent_autonomous_transactions=55.55", )
        self.assertFalse(msg, '执行失败:' + step_txt)

    def tearDown(self):
        self.log.info('----this is tearDown----')

        self.log.info(f'----{os.path.basename(__file__)}:执行完毕----')
